package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * 文本数据的写操作实践
 */
public class WriteStringDemo01 {
    public static void main(String[] args) throws IOException {
        String str = ("我爱java。");
        //构建文件输出流对象
        FileOutputStream fos = new FileOutputStream("./f1.txt");
        //写字符数据
        byte[] data = str.getBytes(StandardCharsets.UTF_8);
        fos.write(data);
        str="Hello Tedu";
        fos.write(str.getBytes(StandardCharsets.UTF_8));
        //释放资源
        fos.close();
    }
}
